#include "SalesItem.h"  
#include <iostream>  

SalesItem::SalesItem() : _unitsSold(0), _sellingPrice(0.0), _salePrice(0.0), _discount(0) {}  

SalesItem::SalesItem(const std::string& bookNo, int unitsSold, double sellingPrice, double salePrice, int discount)  
: _bookNo(bookNo), _unitsSold(unitsSold), _sellingPrice(sellingPrice), _salePrice(salePrice), _discount(discount) {}  

std::string SalesItem::isbn() const 
{  
	return _bookNo;  
}  

void SalesItem::input() 
{  
	cout << "Enter ISBN, Units Sold, Selling Price, Sale Price, Discount (%%): ";  
	cin >> _bookNo >> _unitsSold >> _sellingPrice >> _salePrice >> _discount;  
}  

void SalesItem::output() const 

{  
	cout << "ISBN: " << _bookNo << ", Units Sold: " << _unitsSold  
	<< ", Selling Price: $" << _sellingPrice << ", Sale Price: $" << _salePrice  
	<< ", Discount: " << _discount << "%" << std::endl;  
}  

SalesItem& SalesItem::operator=(const SalesItem& other) 
{  
	if (this != &other) 
	{  
		_bookNo = other._bookNo;  
		_unitsSold = other._unitsSold;  
		_sellingPrice = other._sellingPrice;  
		_salePrice = other._salePrice;  
		_discount = other._discount;  
	}  
	return *this;  
}  

void SalesItem::combine(const SalesItem& other) 
{  
	if (_bookNo == other._bookNo) 
	{  
		_unitsSold += other._unitsSold;  
	  
		if (_unitsSold > 100) 
		{  
			_discount = 30;  
		} 
		else if (_unitsSold > 50) 
		{  
			_discount = 20; 
		} 
		else 
		{  
			_discount = 10;  
		}  
	}  
}
